package com.it.flowable.listener;

import lombok.extern.slf4j.Slf4j;
import org.flowable.engine.delegate.TaskListener;
import org.flowable.task.service.delegate.DelegateTask;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class MyTaskListener implements TaskListener {
    
    @Override
    public void notify(DelegateTask task) {
        String eventName = task.getEventName();
        String taskName = task.getName();
        String assignee = task.getAssignee();
        log.warn("[TaskListener] 事件: {} | 任务: {} | 处理人: {}", eventName, taskName, assignee);

        if ("complete".equals(task.getEventName())) {
            String comment = (String) task.getVariable("comment");
            log.warn("[TaskListener]审批意见: " + comment);
        }
    }
}